/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validPhone(str) {
  const regs = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  return regs.test(str)
}

export function validEmail(str) {
  const regs = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
  return regs.test(str)
}

export function validPassword(str) {
  const regs = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@_$!%*#?&])[A-Za-z\d$@_$!%*#?&]{6,18}$/
  return regs.test(str)
}
